import request from '@/config/axios'

// 学期 VO
export interface SemesterVO {
  startDate: Date // 开始日期
  endDate: Date // 结束日期
  status: number // 学期状态 (0:历史学期 1:当前学期 2:新学期)
  academicYearStart: number // 学年开始
  academicYearEnd: number // 学年结束
  type: number // 学期类别 (1:上学期 2:下学期)
}

// 学期 API
export const SemesterApi = {
  // 查询学期分页
  getSemesterPage: async (params: any) => {
    return await request.get({ url: `/system/semester/page`, params })
  },

  // 查询学期详情
  getSemester: async (id: number) => {
    return await request.get({ url: `/system/semester/get?id=` + id })
  },

  // 新增学期
  createSemester: async (data: SemesterVO) => {
    return await request.post({ url: `/system/semester/create`, data })
  },

  // 修改学期
  updateSemester: async (data: SemesterVO) => {
    return await request.put({ url: `/system/semester/update`, data })
  },

  // 删除学期
  deleteSemester: async (id: number) => {
    return await request.delete({ url: `/system/semester/delete?id=` + id })
  },

  // 导出学期 Excel
  exportSemester: async (params) => {
    return await request.download({ url: `/system/semester/export-excel`, params })
  }
}